package com.aliyun.mts.util;

import com.aliyun.oss.ClientConfiguration;
import com.aliyun.oss.OSSClient;

/**
 * 获取OSS服务客户端, OSSClient支持并发请求
 * 
 * @author liwb 2015-11-6 上午11:22:37
 */
public class OSSClientUtil {

    private static OSSClient client;

    static {
        ClientConfiguration conf = new ClientConfiguration();
        // 设置HTTP最大连接数为1024
        conf.setMaxConnections(1024);
        // 设置TCP连接超时为5000毫秒
        conf.setConnectionTimeout(5000);
        // 设置最大的重试次数为3
        conf.setMaxErrorRetry(3);
        // 设置Socket传输数据超时的时间为50000毫秒
        conf.setSocketTimeout(50000);
        client = new OSSClient(AliyunConfig.ossEndPoint,
                AliyunConfig.accessKeyId, AliyunConfig.accessKeySecret, conf);
    }

    public static OSSClient getOSSClient() {
        return client;
    }
}
